class Solution {
public:
    bool IsPopOrder(vector<int>& pushV, vector<int>& popV) {
       int pushi=0,popi=0;
       stack<int> st; 
        while(pushi<pushV.size())
        {
            st.push(pushV[pushi++]);
            while(!st.empty()&&st.top()==popV[popi])
            {
                popi++;
                st.pop();
            }
        }
        return st.empty();
    }
};